<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/page.js"></script>
<title>活动信息</title>
</head>
<body>
	<jsp:include page="navigation.jsp"></jsp:include>
	<div class="container" style="margin-left: 190px;">
		<div class="topbar-inner">
			<div class="myhead">
				<span class="crumb-name">活动信息</span>
			</div>
		</div>
		<form id="pageForm" action="eventinfo" method="post">
			<div class="topbar-inner">
				<div class="search">
					<div class="input-group" style="float: left; width: 218px;">
						<span class="input-group-addon" id="basic-addon1">活动类型：</span> <input type="hidden" name="event_type_hid" value="${ event_type }" /> <select id="event_type" name="event_type" class="form-control">

						</select>
					</div>
					<button type="submit" id="search_btn" class="btn btn-default" style="margin-left: 20px; margin-top: 1px;">查询</button>
				</div>
			</div>

			<div style="margin: 20px 20px 20px 20px; text-align: center;">
				<table class="table table-bordered table-hover table-striped">
					<thead>
						<tr>
							<th>活动名称</th>
							<th>活动类型</th>
							<th>发起人</th>
							<th>活动地点</th>
							<th>简介</th>
							<th>举行时间</th>
							<th>发布时间</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${ list }" var="l">
							<tr>
								<td><c:if test="${fn:length(l.event_name) > 10}">${fn:substring(l.event_name, 0, 7)}...</c:if> <c:if test="${fn:length(l.event_name) <= 10}">${ l.event_name }</c:if></td>
								<td>${ l.event_type }</td>
								<td>${ l.user.user_name }</td>
								<td><c:if test="${fn:length(l.place) > 10}">${fn:substring(l.place, 0, 17)}...</c:if> <c:if test="${fn:length(l.place) <= 10}">${ l.place }</c:if></td>
								<td><c:if test="${fn:length(l.intro) > 20}">${fn:substring(l.intro, 0, 17)}...</c:if> <c:if test="${fn:length(l.intro) <= 20}">${ l.intro }</c:if></td>
								<td><fmt:formatDate value="${ l.event_time }" pattern="yyyy-MM-dd" type="date" dateStyle="long" /></td>
								<td><fmt:formatDate value="${ l.create_time }" pattern="yyyy-MM-dd HH:mm:ss" type="date" dateStyle="long" /></td>
								<td width="17%"><a href="javascript:" onclick="toDetail(${ l.id })">查看详情</a>&emsp;|&emsp;<a href="javascript:" onclick="toJoin(${ l.id })">参与用户</a></td>
							</tr>
						</c:forEach>

					</tbody>
				</table>
				<input type="hidden" value="${ page.pageCount }" id="pageCount" name="pageCount" /> <input type="hidden" value="${ page.pageIndex }" id="pageIndex" name="pageIndex" />
				<c:if test="${ page == null }">
					<div style="font-size: larger;">暂无数据</div>
				</c:if>
				<c:if test="${ page != null && page.pageCount > 1}">

					<ul id="pagination" class="pagination">

					</ul>

					<script type="text/javascript">
    setPage(document.getElementById("pagination"),parseInt($("#pageCount").val()),parseInt($("#pageIndex").val()));
</script>
				</c:if>
			</div>
		</form>
	</div>
	<script type="text/javascript">
$(function() {
    $('.submenu_1_3').addClass('submenu_native');
    
    $.ajax({
        type : 'post',
        url: 'alleventtype',
        success : function (data) {
            var event_type_hid = $('input[name=event_type_hid]').val();
            var html = '<option value="">全部</option>';
            $.each(data.list, function(item, value) {
                html += '<option value="'+value.type_name+'" ';
                if (value.type_name == event_type_hid) {
                    html += ' selected=selected ';
                }
                html += ' >'+value.type_name+'</option>';
            });
            $('#event_type').empty();
            $('#event_type').append(html);
        }
    });
    
});

function toDetail(id) {
    window.location.href = 'eventinfodetail?id=' + id;
}

function toJoin(id){
    window.location.href = "eventJoin?id="+id;
}
</script>
</body>

</html>